/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * EbookSetting.java
 *
 * Created on 2011-4-25, 16:40:35
 */
package com.iduxs.collect.frame.system;

import com.iduxs.collect.utils.Utility;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Administrator
 */
public class EbookSettingPanel extends javax.swing.JPanel {

    /** Creates new form EbookSetting */
    public EbookSettingPanel() {
        initComponents();
        init();
    }

    private void init() {
        EbookSetting es = new EbookSetting();
        try {
            Utility.readXMLFile("EbookSetting.xml", es);
            bottomAdvertiseText.setText(es.getBottomAdvertise());
            chmPathText.setText(es.getChmPath());
            remoteChmPathText.setText(es.getRemoteChmPath());
            remoteJarPathText.setText(es.getRemoteJarPath());
            remoteTxtPathText.setText(es.getRemoteTxtPath());
            remoteUmdPathText.setText(es.getRemoteUmdPath());
            remoteZipPathText.setText(es.getRemoteZipPath());
            topAdvertiseText.setText(es.getTopAdvertise());
            txtPathText.setText(es.getTxtPath());
            umdPathText.setText(es.getUmdPath());
            useChmBox.setSelected(es.getUseChm());
            useJarBox.setSelected(es.getUseJar());
            useTxtBox.setSelected(es.getUseTxt());
            useUmdBox.setSelected(es.getUseUmd());
            useZipBox.setSelected(es.getUseZip());
            zipPathText.setText(es.getZipPath());
            jarPathText.setText(es.getJarPath());
        } catch (Exception ex) {
            Logger.getLogger(EbookSettingPanel.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        useZipBox = new javax.swing.JCheckBox();
        useTxtBox = new javax.swing.JCheckBox();
        useUmdBox = new javax.swing.JCheckBox();
        useJarBox = new javax.swing.JCheckBox();
        useChmBox = new javax.swing.JCheckBox();
        jPanel1 = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        topAdvertiseText = new javax.swing.JTextArea();
        jScrollPane2 = new javax.swing.JScrollPane();
        bottomAdvertiseText = new javax.swing.JTextArea();
        zipPathText = new javax.swing.JTextField();
        remoteZipPathText = new javax.swing.JTextField();
        remoteTxtPathText = new javax.swing.JTextField();
        txtPathText = new javax.swing.JTextField();
        remoteUmdPathText = new javax.swing.JTextField();
        umdPathText = new javax.swing.JTextField();
        jarPathText = new javax.swing.JTextField();
        remoteJarPathText = new javax.swing.JTextField();
        chmPathText = new javax.swing.JTextField();
        remoteChmPathText = new javax.swing.JTextField();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();

        jLabel1.setFont(new java.awt.Font("宋体", 0, 12));
        jLabel1.setText("硬盘路径");

        jLabel2.setFont(new java.awt.Font("宋体", 0, 12));
        jLabel2.setText("网站路径");

        useZipBox.setFont(new java.awt.Font("宋体", 0, 12));
        useZipBox.setText("生成ZIP");

        useTxtBox.setFont(new java.awt.Font("宋体", 0, 12));
        useTxtBox.setText("生成TXT");

        useUmdBox.setFont(new java.awt.Font("宋体", 0, 12));
        useUmdBox.setText("生成UMD");

        useJarBox.setFont(new java.awt.Font("宋体", 0, 12));
        useJarBox.setText("生成JAR");

        useChmBox.setFont(new java.awt.Font("宋体", 0, 12));
        useChmBox.setText("生成CHM");
        useChmBox.setEnabled(false);

        jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel3.setFont(new java.awt.Font("宋体", 0, 12));
        jLabel3.setText("电子书头增加广告代码");

        jLabel4.setFont(new java.awt.Font("宋体", 0, 12));
        jLabel4.setText("电子书尾增加广告代码");

        topAdvertiseText.setColumns(20);
        topAdvertiseText.setRows(5);
        jScrollPane1.setViewportView(topAdvertiseText);

        bottomAdvertiseText.setColumns(20);
        bottomAdvertiseText.setRows(5);
        jScrollPane2.setViewportView(bottomAdvertiseText);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(24, 24, 24)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 263, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel4)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 271, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(30, 30, 30))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(jLabel4))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 106, Short.MAX_VALUE)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 106, Short.MAX_VALUE))
                .addContainerGap())
        );

        jButton1.setFont(new java.awt.Font("宋体", 0, 12));
        jButton1.setText("确定");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jButton2.setFont(new java.awt.Font("宋体", 0, 12));
        jButton2.setText("取消");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(useTxtBox)
                            .addComponent(useUmdBox)
                            .addComponent(useZipBox))
                        .addGap(10, 10, 10)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(zipPathText, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 258, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtPathText, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 258, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(umdPathText, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 258, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jarPathText, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 258, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(chmPathText, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 258, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(remoteTxtPathText, javax.swing.GroupLayout.PREFERRED_SIZE, 258, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(remoteJarPathText, javax.swing.GroupLayout.PREFERRED_SIZE, 258, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(remoteUmdPathText, javax.swing.GroupLayout.PREFERRED_SIZE, 258, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(remoteChmPathText, javax.swing.GroupLayout.PREFERRED_SIZE, 258, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel2)
                            .addComponent(remoteZipPathText, javax.swing.GroupLayout.PREFERRED_SIZE, 258, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(41, 41, 41))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(jButton1)
                        .addGap(18, 18, 18)
                        .addComponent(jButton2)
                        .addGap(40, 40, 40))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(77, 77, 77)
                        .addComponent(jLabel1)
                        .addGap(515, 515, 515))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(useChmBox)
                        .addContainerGap(573, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(useJarBox)
                        .addContainerGap(573, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 610, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap())))
        );

        layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {remoteChmPathText, remoteJarPathText, remoteTxtPathText, remoteUmdPathText, remoteZipPathText});

        layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {chmPathText, jarPathText, txtPathText, umdPathText, zipPathText});

        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addContainerGap()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel1)
                                    .addComponent(jLabel2)))
                            .addGroup(layout.createSequentialGroup()
                                .addGap(28, 28, 28)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(useZipBox)
                                    .addComponent(remoteZipPathText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(zipPathText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(useTxtBox)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(txtPathText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(remoteTxtPathText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(26, 26, 26)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(useJarBox)
                                    .addComponent(jarPathText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(remoteJarPathText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(remoteUmdPathText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(umdPathText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(useChmBox)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(chmPathText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(remoteChmPathText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(81, 81, 81)
                        .addComponent(useUmdBox)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton2)
                    .addComponent(jButton1))
                .addContainerGap(34, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        EbookSetting es = new EbookSetting();
        es.setBottomAdvertise(bottomAdvertiseText.getText().trim());
        es.setChmPath(chmPathText.getText().trim());
        es.setRemoteChmPath(remoteChmPathText.getText().trim());
        es.setRemoteJarPath(remoteJarPathText.getText().trim());
        es.setRemoteTxtPath(remoteTxtPathText.getText().trim());
        es.setRemoteUmdPath(remoteUmdPathText.getText().trim());
        es.setRemoteZipPath(remoteZipPathText.getText().trim());
        es.setTopAdvertise(topAdvertiseText.getText().trim());
        es.setTxtPath(txtPathText.getText().trim());
        es.setUmdPath(umdPathText.getText().trim());
        es.setUseChm(useChmBox.isSelected());
        es.setUseJar(useJarBox.isSelected());
        es.setUseTxt(useTxtBox.isSelected());
        es.setUseUmd(useUmdBox.isSelected());
        es.setUseZip(useZipBox.isSelected());
        es.setZipPath(zipPathText.getText().trim());
        es.setJarPath(jarPathText.getText().trim());
        try {
            Utility.writeXMLFile("EbookSetting.xml", es);
        } catch (Exception ex) {
            Logger.getLogger(EbookSettingPanel.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jButton1ActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextArea bottomAdvertiseText;
    private javax.swing.JTextField chmPathText;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTextField jarPathText;
    private javax.swing.JTextField remoteChmPathText;
    private javax.swing.JTextField remoteJarPathText;
    private javax.swing.JTextField remoteTxtPathText;
    private javax.swing.JTextField remoteUmdPathText;
    private javax.swing.JTextField remoteZipPathText;
    private javax.swing.JTextArea topAdvertiseText;
    private javax.swing.JTextField txtPathText;
    private javax.swing.JTextField umdPathText;
    private javax.swing.JCheckBox useChmBox;
    private javax.swing.JCheckBox useJarBox;
    private javax.swing.JCheckBox useTxtBox;
    private javax.swing.JCheckBox useUmdBox;
    private javax.swing.JCheckBox useZipBox;
    private javax.swing.JTextField zipPathText;
    // End of variables declaration//GEN-END:variables
}
